'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 副本记录
 * @author sundbcn@gmail.com (sun debing)
 */

var mongoConnector = require('../libs/mongodb/mongoConnector');
/* jshint unused:false */
var redPacketSchema = require('../schemas/redPacketSchema');
var RedPacket = mongoConnector().model('RedPacket');

/**
 * 添加一个支付记录
 */
module.exports.create = function (remain_num, reward_type, min_red_packet, max_red_packet, spec_red_packet, cb) {
    // 创建成功后
    function afterCreate(err, model) {
        cb(err, model);
    }

    RedPacket.create({
        remain_num: remain_num,
        reward_type: reward_type,
        min_red_packet: min_red_packet,
        max_red_packet: max_red_packet,
        spec_red_packet: spec_red_packet
    }, afterCreate);
};

/**
 * 获取订单
 * @param  {[type]}   order_id [description]
 * @param  {Function} cb       [description]
 * @return {[type]}            [description]
 */
module.exports.getById = function (red_packet_id, cb) {
    RedPacket.findOne({
        red_packet_id: red_packet_id
    }, cb);
};
